#include "stdafx.h"
#include "ckRule.h"
#include "ckConstraint.h"

namespace ck
{

	OpRule::OpRule()
	{
	}


	OpRule::~OpRule()
	{
		std::vector<Constraint*>::iterator iter;
		for (iter = m_constraints.begin(); iter != m_constraints.end(); iter++)
		{
			(*iter)->Release();
		}
		m_constraints.clear();
	}

	z_uint32 OpRule::GetCount()
	{
		return m_constraints.size();
	}

	Constraint*	OpRule::GetConstraint(z_uint32 i)
	{
		if (i >= m_constraints.size())
		{
			return NULL;
		}
		return m_constraints[i];
	}

	RESULTCODE	OpRule::Add(Constraint* pConstraint)
	{
		if(!pConstraint)
		{
			return RC_FAILURE;
		}

		m_constraints.push_back(pConstraint);
		return RC_SUCCESS;
	}

	const char* OpRule::GetDescription()
	{
		return m_strDescription.c_str();
	}

}